using UnityEngine;
using System.Collections;

public class PExplosion : MonoBehaviour 
{
	public bool pushButton;
	public Button button;

    int frameEnter;
	
	void Start () 
	{
        frameEnter = Time.frameCount;
	//	GameObject.Find("Button").transform.rigidbody.WakeUp();
	}
	
	void Update () 
	{
       

        if ( Time.frameCount> frameEnter  )
        {
            Destroy(gameObject);
        }
	}


    
	void OnTriggerStay(Collider element)
	{
	/*	GameObject.Find("Button").transform.rigidbody.WakeUp();
		*/
		Vector3 vec= element.transform.position-this.transform.position ;
        vec.Normalize();

		if(element.tag=="Cube")
		{
			element.transform.rigidbody.AddForce(vec*1500.0f);
		}
		else if(element.tag=="Char")
		{
			element.transform.rigidbody.AddForce(vec*1500.0f);
		}
	}
	
}
